Skip to content

feat!: Replace isAccessibleCallback with diagnosticsSummaryCallback in DoenetEditor#1035

Merged
dqnykamp merged 5 commits intoDoenet:mainfrom
dqnykamp:diagnostic-summary-callback
May 1, 2026
Merged

feat!: Replace isAccessibleCallback with diagnosticsSummaryCallback in DoenetEditor#1035
dqnykamp merged 5 commits intoDoenet:mainfrom
dqnykamp:diagnostic-summary-callback

Conversation

@dqnykamp
Copy link
Copy Markdown
Member

@dqnykamp dqnykamp commented May 1, 2026

Summary

Replaces the isAccessibleCallback prop on DoenetEditor (and the underlying EditorViewer) with a new diagnosticsSummaryCallback prop.

Before

isAccessibleCallback?: (isAccessible: boolean) => void;

The callback fired with a single boolean indicating whether there were no level-1 accessibility issues.

After

diagnosticsSummaryCallback?: (diagnosticsSummary: Record<string, number>) => void;

The callback now fires with an object containing counts for all diagnostic categories:

{
  warningsCount: number,
  errorsCount: number,
  infosCount: number,
  accessibilityLevel1Count: number,
  accessibilityLevel2Count: number,
}

Additional changes

  • The callback is only invoked after diagnostics have actually been received from the viewer, preventing a spurious initial call with only the initial diagnostics passed in from outside the editor.
  • mergeDiagnosticsByType now also returns warningsCount, errorsCount, and infosCount.
  • Accessibility tests updated to exercise the new callback shape.

Co-authored-by: Copilot <copilot@github.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 1, 2026

🦋 Changeset detected

Latest commit: 023d2d3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@doenet/doenetml Patch
@doenet/standalone Patch
@doenet/doenetml-iframe Patch
@doenet/vscode-extension Patch
doenet-vscode-extension Patch
@doenet/v06-to-v07 Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dqnykamp dqnykamp changed the title Replace isAccessibleCallback with diagnosticsSummaryCallback in DoenetEditor feat!: Replace isAccessibleCallback with diagnosticsSummaryCallback in DoenetEditor May 1, 2026
@dqnykamp dqnykamp requested a review from Copilot May 1, 2026 03:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the DoenetML editor API by replacing the boolean isAccessibleCallback with a more general diagnosticsSummaryCallback that reports diagnostic counts across categories, and wires it through DoenetEditorEditorViewer. It also updates Cypress coverage to validate the new callback payload.

Changes:

  • Replace isAccessibleCallback(isAccessible: boolean) with diagnosticsSummaryCallback(summary) in DoenetEditor/EditorViewer.
  • Extend mergeDiagnosticsByType to return warningsCount, errorsCount, and infosCount alongside accessibility counts.
  • Update Cypress tests and the Cypress test harness to read/verify the new summary object (including new warning/error tests).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/test-cypress/src/CypressTest.tsx Update Cypress harness to capture the new diagnostics summary callback payload.
packages/test-cypress/cypress/e2e/EditorViewer/editorViewerAccessibilityReport.cy.js Update/add Cypress assertions to validate new callback shape and counts.
packages/doenetml/src/doenetml.tsx Replace public DoenetEditor prop with diagnosticsSummaryCallback and pass through to EditorViewer.
packages/doenetml/src/EditorViewer/diagnostics.ts Add warning/error/info count fields to merged diagnostics result.
packages/doenetml/src/EditorViewer/EditorViewer.tsx Invoke diagnosticsSummaryCallback only after viewer diagnostics have been received.
.changeset/diagnostics-summary-callback.md Add changeset describing the callback replacement and behavior change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/doenetml/src/doenetml.tsx
Comment thread packages/doenetml/src/EditorViewer/EditorViewer.tsx
Comment thread .changeset/diagnostics-summary-callback.md
Co-authored-by: Copilot <copilot@github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Doenet editor/viewer diagnostics API by replacing the boolean isAccessibleCallback with a richer diagnosticsSummaryCallback that reports counts across diagnostic categories, and adjusts Cypress tests/harness to validate the new behavior.

Changes:

  • Replaced isAccessibleCallback with diagnosticsSummaryCallback on DoenetEditor and EditorViewer, emitting counts for warnings/errors/infos and accessibility levels.
  • Extended mergeDiagnosticsByType to return warningsCount, errorsCount, and infosCount alongside existing grouped diagnostics.
  • Updated Cypress test harness and E2E accessibility/diagnostics tests to use the new callback shape.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/test-cypress/src/CypressTest.tsx Switches Cypress harness from isAccessibleCallback to diagnosticsSummaryCallback and exposes the latest summary via window.returnDiagnosticsSummaryCallbackValue().
packages/test-cypress/cypress/e2e/EditorViewer/editorViewerAccessibilityReport.cy.js Updates/expands E2E assertions to validate the new diagnostics summary counts for accessibility, warnings, and errors.
packages/doenetml/src/doenetml.tsx Updates DoenetEditor public prop type and forwards diagnosticsSummaryCallback into EditorViewer.
packages/doenetml/src/EditorViewer/diagnostics.ts Introduces DiagnosticsSummary type and adds warnings/errors/infos counts to mergeDiagnosticsByType return value.
packages/doenetml/src/EditorViewer/EditorViewer.tsx Adds gating to avoid emitting summary before viewer diagnostics arrive and emits the new summary payload.
.changeset/diagnostics-summary-callback.md Adds release note for the callback replacement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/doenetml/src/EditorViewer/EditorViewer.tsx Outdated
Comment thread .changeset/diagnostics-summary-callback.md
Comment thread packages/test-cypress/src/CypressTest.tsx
Addresses two PR review comments:

1. Memoize the diagnosticsSummary object in EditorViewer via useMemo
   so its reference is stable when counts don't change, avoiding
   potential render loops when consumers store the object in state.

2. Reset diagnosticsSummaryRef in CypressTest when doenetMLstring
   changes, ensuring stale summary values from previous test runs
   aren't returned to subsequent tests.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the isAccessibleCallback API on DoenetEditor/EditorViewer with a richer diagnosticsSummaryCallback that reports counts across diagnostic categories, and updates diagnostics aggregation + Cypress coverage accordingly.

Changes:

  • Replace isAccessibleCallback(isAccessible: boolean) with diagnosticsSummaryCallback(diagnosticsSummary) across DoenetEditor and EditorViewer.
  • Extend mergeDiagnosticsByType to return warningsCount, errorsCount, and infosCount in addition to accessibility counts.
  • Update Cypress harness + E2E tests to assert the new callback payload (including warning/error counts).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/test-cypress/src/CypressTest.tsx Switch Cypress harness window hook and editor prop wiring to the new diagnostics summary callback.
packages/test-cypress/cypress/e2e/EditorViewer/editorViewerAccessibilityReport.cy.js Update and expand E2E assertions to validate the new summary shape and counts.
packages/doenetml/src/doenetml.tsx Update DoenetEditor public prop surface to accept diagnosticsSummaryCallback.
packages/doenetml/src/EditorViewer/diagnostics.ts Introduce DiagnosticsSummary type and extend mergeDiagnosticsByType to compute counts.
packages/doenetml/src/EditorViewer/EditorViewer.tsx Emit the new diagnostics summary via callback (with a “received from viewer” gate).
.changeset/diagnostics-summary-callback.md Document the API replacement in Changesets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/doenetml/src/EditorViewer/EditorViewer.tsx
Comment thread .changeset/diagnostics-summary-callback.md
@dqnykamp dqnykamp requested a review from cqnykamp May 1, 2026 13:38
Copy link
Copy Markdown
Collaborator

@cqnykamp cqnykamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good as far as I can tell.

Co-authored-by: Copilot <copilot@github.com>
@dqnykamp dqnykamp requested a review from Copilot May 1, 2026 14:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Doenet editor diagnostics callback API by replacing the boolean isAccessibleCallback with a richer diagnosticsSummaryCallback that reports counts for multiple diagnostic categories, and updates Cypress tests accordingly.

Changes:

  • Replace isAccessibleCallback with diagnosticsSummaryCallback on DoenetEditor/EditorViewer.
  • Extend mergeDiagnosticsByType to also return warning/error/info counts and emit a memoized DiagnosticsSummary.
  • Update Cypress test harness and e2e tests to assert the new callback shape and behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/test-cypress/src/CypressTest.tsx Updates the test harness to expose diagnostics summary via a window callback and resets it on new DoenetML.
packages/test-cypress/cypress/e2e/EditorViewer/editorViewerAccessibilityReport.cy.js Updates/extends Cypress assertions to validate the new summary counts (accessibility, warnings, errors).
packages/doenetml/src/doenetml.tsx Swaps DoenetEditor prop from isAccessibleCallback to diagnosticsSummaryCallback and wires it through to EditorViewer.
packages/doenetml/src/EditorViewer/diagnostics.ts Adds DiagnosticsSummary type and returns warning/error/info counts from mergeDiagnosticsByType.
packages/doenetml/src/EditorViewer/EditorViewer.tsx Implements gated + memoized diagnosticsSummaryCallback invocation based on viewer diagnostics receipt.
.changeset/diagnostics-summary-callback.md Adds a changeset entry describing the callback replacement and new payload shape.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/doenetml/src/EditorViewer/EditorViewer.tsx
Comment thread packages/doenetml/src/EditorViewer/diagnostics.ts Outdated
@dqnykamp dqnykamp merged commit 9650a0f into Doenet:main May 1, 2026
17 checks passed
@dqnykamp dqnykamp deleted the diagnostic-summary-callback branch May 1, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants